home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / PNL Libraries / MyExpiry.p < prev    next >
Encoding:
Text File  |  1995-10-22  |  1.6 KB  |  69 lines  |  [TEXT/CWIE]

  1. unit MyExpiry;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Types;
  7.  
  8.     function ExpiredVersion (cs:longint; notify, expire: integer): boolean;
  9. { Pass it compdate, and the number of months until it notifies/expires }
  10.  
  11. implementation
  12.  
  13.     uses
  14.         OSUtils, MyStrings, MyVersionResource, MyEmergencyNotifier, MyUtils;
  15.  
  16.     procedure GetCompiledDate (cd: Str255; var date: longint);
  17.         var
  18.             d: DateTimeRec;
  19.             s: str31;
  20.             p: integer;
  21.     begin
  22.         s := cd;
  23.         p := TPPos('/', s);
  24.         d.day := StrToNum(TPCopy(s, 1, p - 1));
  25.         Delete(s, 1, p);
  26.         p := TPPos('/', s);
  27.         d.month := StrToNum(TPCopy(s, 1, p - 1));
  28.         Delete(s, 1, p);
  29.         d.year := 1900 + StrToNum(s);
  30.         d.hour := 0;
  31.         d.minute := 0;
  32.         d.second := 0;
  33.         DateToSeconds(d, date);
  34.     end;
  35.  
  36.     function ExpiredVersion (cs:longint; notify, expire: integer): boolean;
  37.         var
  38.             date, diff: longint;
  39.             vers: versionRecord;
  40.     begin
  41.         ExpiredVersion := false;
  42.         GetVersion(vers);
  43.         if vers.numericVersion.stage <> $80 then begin
  44.             GetDateTime(date);
  45.             if compsecs > cs then begin
  46.                 cs := compsecs;
  47.             end;
  48.             diff := (date - cs) div 2678400;
  49.             if diff >= expire then begin
  50.                 EmergencyNotify('This developmental version has expired.  Set your clock back, or get a new version');
  51.                 ExpiredVersion := true;
  52.             end
  53.             else if diff >= notify then begin
  54.                 EmergencyNotify('This developmental version has expired.  It will work for a while, and then stop working forever.  Get a new version');
  55.             end;
  56.         end;
  57.     end;
  58.  
  59.  
  60. end.
  61.         GetVersion(vers);
  62.         if vers.devcode <> $80 then begin
  63.             GetDateTime(date);
  64.             GetCompiledDate(cd, cdate);
  65.             GetCompiledDate(compdate, cdate2);
  66.             if cdate2 > cdate then begin
  67.                 cdate := cdate2;
  68.             end;
  69.